package com.xc.ezplan.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.ezplan.admin.entity.AdminAliConfig;
import com.xc.ezplan.admin.entity.AdminEmailConfig;
import com.xc.ezplan.admin.service.AdminEmailConfigService;
import com.xc.ezplan.admin.mapper.AdminEmailConfigMapper;
import com.xc.ezplan.admin.vo.AdminEmailConfigVo;
import com.xc.ezplan.core.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lixingchen
 * @date 2022/12/10
 * @description 邮件配置实现类
 */
@Service
@Primary
@RequiredArgsConstructor
public class AdminEmailConfigServiceImpl extends ServiceImpl<AdminEmailConfigMapper, AdminEmailConfig>
    implements AdminEmailConfigService{

    private final AdminEmailConfigMapper adminEmailConfigMapper;

    @Override
    public void createEmailConfig(AdminEmailConfigVo adminEmailConfigVo) {
        AdminEmailConfig adminEmailConfig = new AdminEmailConfig();
        BeanUtils.copyProperties(adminEmailConfigVo,adminEmailConfig);
        adminEmailConfigMapper.insert(adminEmailConfig);
    }

    @Override
    public void updateEmailConfig(AdminEmailConfigVo adminEmailConfigVo) {

    }

    @Override
    public void deleteEmailConfig(List<Long> ids) {
        adminEmailConfigMapper.deleteBatchIds(ids);
    }

    @Override
    public Object queryEmailConfig(Long id) {
        return adminEmailConfigMapper.selectById(id);
    }

    @Override
    public Object queryAllEmailConfig(String keyWord) {
        LambdaQueryWrapper<AdminEmailConfig> queryWrapper = new QueryWrapper<AdminEmailConfig>().lambda().like(
                StringUtils.isNotBlank(keyWord), AdminEmailConfig::getUser,
                keyWord);
        return adminEmailConfigMapper.selectList(queryWrapper);
    }
}




